package vistasSucursal;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.WindowConstants;

import controlador.ControladorSuc;
import dto.MesaDTO;
import dto.MesaSimpleDTO;
import dto.SectorDTO;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AperturaMesaCompuesta extends javax.swing.JFrame {
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel mesasComponentes;
	private JButton abrirMesa;
	private JList comboMesasSimpl;
	private JButton armarMesa;
	private JTextField comensales;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public AperturaMesaCompuesta() {
		super();
		initGUI();
	}
	
	public void setComensales(String texto) {
		this.comensales.setText(texto);
	}

	private void initGUI() {
		try {
			{
				this.setSize(596, 302);
			}
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				jLabel1 = new JLabel();
				getContentPane().add(jLabel1);
				jLabel1.setText("Abrir Mesa Compuesta");
				jLabel1.setBounds(25, 18, 158, 16);
			}
			{
				jLabel2 = new JLabel();
				getContentPane().add(jLabel2);
				jLabel2.setText("Cantidad de Comensales");
				jLabel2.setBounds(25, 64, 155, 16);
			}
			{
				comensales = new JTextField();
				getContentPane().add(comensales);
				comensales.setBounds(183, 61, 54, 23);
			}
			{
				armarMesa = new JButton();
				getContentPane().add(armarMesa);
				armarMesa.setText("Armar Mesa");
				armarMesa.setBounds(263, 61, 216, 23);
				armarMesa.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						SectorDTO sec=new SectorDTO();
						int id=1;
						sec.setIdSector(id);
						
						List<MesaDTO> mesas = ControladorSuc.getInstancia().armarMesaCompuesta(sec, Integer.parseInt(comensales.getText()));
						
						comboMesasSimpl.removeAll();
						/*
						if (mesas != null) {
							for (MesaDTO m:mesas){
	//							Object[] object = new Object[3];
	//							object[1]=m.getNumero();
	//							object[2]=" ";
	//							object[3]=m.getIdMesa();
								comboMesasSimpl.setModel(m);add(m);
							}
						}*/
					}
				});
			}
			{
				mesasComponentes = new JLabel();
				getContentPane().add(mesasComponentes);
				mesasComponentes.setText("Mesas componentes");
				mesasComponentes.setBounds(25, 126, 138, 16);
			}
			{
				abrirMesa = new JButton();
				getContentPane().add(abrirMesa);
				abrirMesa.setText("Abrir Mesa");
				abrirMesa.setBounds(25, 286, 121, 23);
				/*
				abrirMesa.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						/*
						List<MesaSimpleDTO> mesas=new ArrayList<MesaSimpleDTO>();
						for(int i=1;i<=comboMesas.getComponentCount();i++){
							mesas.add((MesaSimpleDTO)comboMesas.getComponentAt(i));
						}
						
						ControladorSuc.getInstancia().abrirMesaComp(comboMesas, mozo);
				}
				);*/
				
			}
				{
					ListModel comboMesasSimplModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					comboMesasSimpl = new JList();
					getContentPane().add(comboMesasSimpl);
					comboMesasSimpl.setModel(comboMesasSimplModel);
					comboMesasSimpl.setBounds(181, 126, 299, 114);
				}
			pack();
			this.setSize(514, 385);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
